﻿/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 
*     ___                              __                 _       __              __     __       *
*    /   |   _____ ____   ___   _____ /_/____   ____     | |     / /____   _____ / /____/ /_____  *
*   / /| |  / ___// __ \ / _ \ / ___// // __ \ / __ \    | | /| / // __ \ / ___// // __  // ___/  *
*  / ___ | _\_ \ / /_/ //  __// /   / // /_/ // / / /    | |/ |/ // /_/ // /   / // /_/ /_\_ \    *
* /_/  |_|/____// ____/ \___//_/   /_/ \____//_/ /_/     |__/|__/ \____//_/   /_/ \____//____/    *
*              /_/                                                                                *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*/

using System;
using System.Collections.Generic;
using System.Linq;
using Worlds.Versions;
using Worlds.Application;

namespace Server
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    public static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            /* Before we verify the library files we can not trust the error handler in Worlds.Applicaiton. */
            try
            {
                /* Load the library file information. */
                VersionHelper Worlds_Versions = new VersionHelper("Worlds.Versions.dll");
                VersionHelper Worlds_Application = new VersionHelper("Worlds.Application.dll");

                /* Now check the versions. */
                Worlds_Versions.check("1.0.0");
                Worlds_Application.check("1.0.0");

                /* Now that we have verified the library files we are good to use the error handler in Worlds.Applicaiton.  */
                try
                {
                    /* Have the Worlds.Applicaiton run the common startup logic. */
                    Application.start();

                    /* Pass off the thread to our internal framework now. */
                    Framework.Main.start();
                    Framework.Main.stop();

                    /* Have the Worlds.Applicaiton run the common shutdown logic. */
                    Application.stop();
                }
                catch (Exception e)
                {

                }
            }
            catch (Exception e)
            {
                /* Show them what went wrong. */
                System.Windows.Forms
                    .MessageBox.Show(e.Message, "Asperion Worlds", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
    }
}
